﻿using System;
using System.Windows.Forms;

namespace Texpro
{
    public partial class FMMN105 : Form
    {

        String record_id = String.Empty;
        String form_report_file = String.Empty;
        int zoom_scale = 1;

        public FMMN105()
        {
            InitializeComponent();
            zoom_report(zoom_scale);
        }

        private void FMRP101_Load(object sender, EventArgs e)
        {
            set_form_size();
            form_report_file = PCREP.m_local_report_path + PCREP.m_local_report_file;
            dtp_date_from.Enabled = true;
            dtp_date_upto.Enabled = true;
            lst_vendor_type.Enabled = false;
            lst_vendor.Enabled = false;
            lst_city.Enabled = false;
            PCPUB.m_fill_combo(lst_vendor_type, "VENDOR_TYPE");
            PCPUB.m_fill_combo(lst_vendor, "NONE");
            PCPUB.m_fill_combo(lst_city, "CITY");
            switch (this.Tag.ToString())
            {
                case "RPTR103":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "YARN_VENDOR");
                    break;
                case "RPTR104":
                    lst_city.Enabled = true;
                    break;
                case "RPTR113":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "YARN_BUYER");
                    break;
                case "RPTR114":
                    lst_city.Enabled = true;
                    break;
                case "RPTR123":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "YARN_VENDOR");
                    break;
                case "RPTR124":
                    lst_city.Enabled = true;
                    break;
                case "RPTR131":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "YARN_VENDOR");
                    break;
                case "RPTR203":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "DYER");
                    break;
                case "RPTR204":
                    lst_city.Enabled = true;
                    break;
                case "RPTR213":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "DYER");
                    break;
                case "RPTR214":
                    lst_city.Enabled = true;
                    break;
                case "RPTR303":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WEAVER");
                    break;
                case "RPTR304":
                    lst_city.Enabled = true;
                    break;
                case "RPTR313":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WEAVER");
                    break; 
                case "RPTR314":
                    lst_city.Enabled = true;
                    break;
                case "RPTR323":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WEAVER");
                    break;     
                case "RPTR331":
                    dtp_date_from.Enabled = false;
                    break;
                case "RPTR332":
                    dtp_date_from.Enabled = false;
                    break;
                case "RPTR333":
                    dtp_date_from.Enabled = false;
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WEAVER");
                    break;
                case "RPTR403":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WASHER");
                    break;
                case "RPTR404":
                    lst_city.Enabled = true;
                    break;
                case "RPTR413":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "WASHER");
                    break;
                case "RPTR414":
                    lst_city.Enabled = true;
                    break;
                case "RPTR503":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "TAILOR");
                    break;
                case "RPTR504":
                    lst_city.Enabled = true;
                    break;
                case "RPTR513":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "TAILOR");
                    break;
                case "RPTR514":
                    lst_city.Enabled = true;
                    break;
                case "RPTR531":
                    lst_vendor.Enabled = true;
                    dtp_date_from.Enabled = false;
                    PCPUB.m_fill_combo(lst_vendor, "TAILOR");
                    break;
                case "RPTR532":
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "TAILOR");
                    break;
                case "RPTR603":
                    lst_vendor_type.Enabled = true;
                    lst_vendor.Enabled = true;
                    PCPUB.m_fill_combo(lst_vendor, "NONE");
                    break;
                case "RPTR604":
                    lst_vendor_type.Enabled = true;
                    lst_vendor.Enabled = true;
                    dtp_date_from.Enabled = false;
                    PCPUB.m_fill_combo(lst_vendor, "NONE");
                    break;
            }
            clear_form();

        }

        private void load_report()
        {
            int i = 0;
            int dc = 0;
            String rep_org_name = String.Empty;
            String rep_org_address = String.Empty;
            //
            try
            {
                UseWaitCursor = true;
                rep_org_name = PCPUB.mc_org_name.ToString();
                rep_org_address = PCPUB.mc_org_address1.ToString();
                rep_org_address += ", " + PCPUB.mc_org_address2.ToString();
                rep_org_address += ", " + PCPUB.mc_org_address3.ToString();
                rep_org_address += ", " + PCPUB.mc_org_city.ToString();
                rep_org_address += ". Pin:" + PCPUB.mc_org_pincode.ToString();
                rep_org_address += "  Phone:" + PCPUB.mc_org_phone1.ToString();
                rd1.FileName = form_report_file.ToString();
                rd1.SetParameterValue("p_org_name", rep_org_name.ToString());
                rd1.SetParameterValue("p_org_address", rep_org_address.ToString());
                //
                switch (this.Tag.ToString())
                {
                    case "RPTR102":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR103":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR104":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR105":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR112":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR113":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR114":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR115":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR122":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR123":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR124":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR125":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR131":
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR202":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR203":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR204":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR205":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR212":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR213":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR214":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR215":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR302":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR303":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR304":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR305":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR312":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR313":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR314":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR315":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR322":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR323":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR331":
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR332":
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR333":
                        double p_weaver_prev_week_weight_os = 0;
                        p_weaver_prev_week_weight_os = PCDB.m_get_weaver_prev_week_weight_os(((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString(), dtp_date_upto.Value.ToString("yyyy-MM-dd"));
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        rd1.SetParameterValue("p_weaver_prev_week_weight_os", p_weaver_prev_week_weight_os);
                        break;
                    case "RPTR402":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR403":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR404":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR405":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR412":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR413":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR414":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR415":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR431":
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR432":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR502":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR503":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR504":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR505":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR512":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR513":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR514":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_city_name", ((m_combo_item)lst_city.SelectedItem).combo_text.ToString());
                        break;
                    case "RPTR515":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR531":
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR532":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR602":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        break;
                    case "RPTR603":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_type_id", ((m_combo_item)lst_vendor_type.SelectedItem).combo_code.ToString());
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                    case "RPTR604":
                        rd1.SetParameterValue("p_date_from", dtp_date_from.Value);
                        rd1.SetParameterValue("p_date_upto", dtp_date_upto.Value);
                        rd1.SetParameterValue("p_vendor_type_id", ((m_combo_item)lst_vendor_type.SelectedItem).combo_code.ToString());
                        rd1.SetParameterValue("p_vendor_id", ((m_combo_item)lst_vendor.SelectedItem).combo_code.ToString());
                        break;
                }
                //
                dc = rd1.DataSourceConnections.Count;
                for (i = 0; i < dc; i++)
                {
                    rd1.DataSourceConnections[i].SetConnection(PCPUB.m_db_server.ToString(), PCPUB.m_db_name.ToString(), PCPUB.m_db_user.ToString(), PCPUB.m_db_password.ToString());
                }
                crv1.ReportSource = rd1;
                zoom_scale = 1;
                crv1.Zoom(zoom_scale);
            }
            catch (Exception ex)
            {
                PCMSG.ShowError(ex);
                rd1.Close();
            }
            UseWaitCursor = false;
        }

        private void FMMN105_FormClosed(object sender, FormClosedEventArgs e)
        {
            rd1.Close();
            switch (this.Tag.ToString())
            {
                case "RPTR102":
                    PCPUB.m_RPTR102_open = false;
                    break;
                case "RPTR103":
                    PCPUB.m_RPTR103_open = false;
                    break;
                case "RPTR104":
                    PCPUB.m_RPTR104_open = false;
                    break;
                case "RPTR105":
                    PCPUB.m_RPTR105_open = false;
                    break;
                case "RPTR131":
                    PCPUB.m_RPTR131_open = false;
                    break;
                case "RPTR112":
                    PCPUB.m_RPTR112_open = false;
                    break;
                case "RPTR113":
                    PCPUB.m_RPTR113_open = false;
                    break;
                case "RPTR114":
                    PCPUB.m_RPTR114_open = false;
                    break;
                case "RPTR115":
                    PCPUB.m_RPTR115_open = false;
                    break;
                case "RPTR122":
                    PCPUB.m_RPTR122_open = false;
                    break;
                case "RPTR123":
                    PCPUB.m_RPTR123_open = false;
                    break;
                case "RPTR124":
                    PCPUB.m_RPTR124_open = false;
                    break;
                case "RPTR125":
                    PCPUB.m_RPTR125_open = false;
                    break;
                case "RPTR202":
                    PCPUB.m_RPTR202_open = false;
                    break;
                case "RPTR203":
                    PCPUB.m_RPTR203_open = false;
                    break;
                case "RPTR204":
                    PCPUB.m_RPTR204_open = false;
                    break;
                case "RPTR205":
                    PCPUB.m_RPTR205_open = false;
                    break;
                case "RPTR212":
                    PCPUB.m_RPTR212_open = false;
                    break;
                case "RPTR213":
                    PCPUB.m_RPTR213_open = false;
                    break;
                case "RPTR214":
                    PCPUB.m_RPTR214_open = false;
                    break;
                case "RPTR215":
                    PCPUB.m_RPTR215_open = false;
                    break;
                case "RPTR231":
                    PCPUB.m_RPTR531_open = false;
                    break;
                case "RPTR232":
                    PCPUB.m_RPTR532_open = false;
                    break;
                case "RPTR302":
                    PCPUB.m_RPTR302_open = false;
                    break;
                case "RPTR303":
                    PCPUB.m_RPTR303_open = false;
                    break;
                case "RPTR304":
                    PCPUB.m_RPTR304_open = false;
                    break;
                case "RPTR305":
                    PCPUB.m_RPTR305_open = false;
                    break;
                case "RPTR312":
                    PCPUB.m_RPTR312_open = false;
                    break;
                case "RPTR313":
                    PCPUB.m_RPTR313_open = false;
                    break;
                case "RPTR314":
                    PCPUB.m_RPTR314_open = false;
                    break;
                case "RPTR315":
                    PCPUB.m_RPTR315_open = false;
                    break;
                case "RPTR322":
                    PCPUB.m_RPTR322_open = false;
                    break;
                case "RPTR323":
                    PCPUB.m_RPTR323_open = false;
                    break;
                case "RPTR331":
                    PCPUB.m_RPTR331_open = false;
                    break;
                case "RPTR332":
                    PCPUB.m_RPTR332_open = false;
                    break;
                case "RPTR333":
                    PCPUB.m_RPTR333_open = false;
                    break;
                case "RPTR402":
                    PCPUB.m_RPTR402_open = false;
                    break;
                case "RPTR403":
                    PCPUB.m_RPTR403_open = false;
                    break;
                case "RPTR404":
                    PCPUB.m_RPTR404_open = false;
                    break;
                case "RPTR405":
                    PCPUB.m_RPTR405_open = false;
                    break;
                case "RPTR412":
                    PCPUB.m_RPTR412_open = false;
                    break;
                case "RPTR413":
                    PCPUB.m_RPTR413_open = false;
                    break;
                case "RPTR414":
                    PCPUB.m_RPTR414_open = false;
                    break;
                case "RPTR415":
                    PCPUB.m_RPTR415_open = false;
                    break;
                case "RPTR431":
                    PCPUB.m_RPTR531_open = false;
                    break;
                case "RPTR432":
                    PCPUB.m_RPTR532_open = false;
                    break;
                case "RPTR502":
                    PCPUB.m_RPTR502_open = false;
                    break;
                case "RPTR503":
                    PCPUB.m_RPTR503_open = false;
                    break;
                case "RPTR504":
                    PCPUB.m_RPTR504_open = false;
                    break;
                case "RPTR505":
                    PCPUB.m_RPTR505_open = false;
                    break;
                case "RPTR512":
                    PCPUB.m_RPTR512_open = false;
                    break;
                case "RPTR513":
                    PCPUB.m_RPTR513_open = false;
                    break;
                case "RPTR514":
                    PCPUB.m_RPTR514_open = false;
                    break;
                case "RPTR515":
                    PCPUB.m_RPTR515_open = false;
                    break;
                case "RPTR531":
                    PCPUB.m_RPTR531_open = false;
                    break;
                case "RPTR532":
                    PCPUB.m_RPTR532_open = false;
                    break;
                case "RPTR602":
                    PCPUB.m_RPTR602_open = false;
                    break;
                case "RPTR603":
                    PCPUB.m_RPTR603_open = false;
                    break;
                case "RPTR604":
                    PCPUB.m_RPTR604_open = false;
                    break;
            }
        }

        private void set_form_size()
        {
            this.Top = PCPUB.m_mdi_child_top;
            this.Left = PCPUB.m_mdi_child_left;
            this.Height = PCPUB.m_mdi_child_height;
            this.Width = PCPUB.m_mdi_child_width;
        }

        private void clear_form()
        {
            dtp_date_from.Value = PCPUB.m_tran_date;
            dtp_date_upto.Value = PCPUB.m_tran_date;
            lst_vendor_type.SelectedIndex = -1;
            lst_vendor.SelectedIndex = -1;
            dtp_date_from.Focus();
        }

        private void pdf_report()
        {
            int exportFormats = (int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat);
            crv1.AllowedExportFormats = exportFormats;
            crv1.ExportReport();
        }

        private void refresh_report()
        {
            crv1.RefreshReport();
        }

        private void sc_main_list_Resize(object sender, EventArgs e)
        {
            sc_main_list.SplitterDistance = 320;
        }

        private void tsb_print_Click(object sender, EventArgs e)
        {
            crv1.PrintReport();
        }

        private void tsb_pdf_Click(object sender, EventArgs e)
        {
            pdf_report();
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tsb_load_Click(object sender, EventArgs e)
        {
            if (validate_form())
            {
                load_report();
            }
        }

        private bool validate_form()
        {
            if (lst_vendor_type.Enabled == true && lst_vendor_type.SelectedIndex == -1)
            {
                PCMSG.Show("Vendor Type field should not be empty.");
                lst_vendor_type.Focus();
                return false;
            }
            else if (lst_vendor.Enabled == true && lst_vendor.SelectedIndex == -1)
            {
                PCMSG.Show("Vendor field should not be empty.");
                lst_vendor.Focus();
                return false;
            }
            return true;
        }

        private void tsb_refresh_Click(object sender, EventArgs e)
        {
            refresh_report();
        }

        private void but_load_Click(object sender, EventArgs e)
        {
            if (validate_form())
            {
                load_report();
            }
        }

        private void tsb_page_first_Click(object sender, EventArgs e)
        {
            crv1.ShowFirstPage();
        }

        private void tsb_page_previous_Click(object sender, EventArgs e)
        {
            crv1.ShowPreviousPage();
        }

        private void tsb_page_next_Click(object sender, EventArgs e)
        {
            crv1.ShowNextPage();
        }

        private void tsb_page_last_Click(object sender, EventArgs e)
        {
            crv1.ShowLastPage();
        }

        private void tsb_zoom_Click(object sender, EventArgs e)
        {
            zoom_scale++;
            if (zoom_scale > 3)
                zoom_scale = 1;
            zoom_report(zoom_scale);
        }

        private void zoom_report(int p_zoom_scale)
        {
            int i_zoom_scale;
            switch (p_zoom_scale)
            {   
                case 2:
                    i_zoom_scale = 2;
                    break;
                case 3:
                    i_zoom_scale = 100;
                    break;
                default:
                    i_zoom_scale = 1;
                    break;
            }
            crv1.Zoom(i_zoom_scale);
        }

        private void lst_vendor_type_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            String tmp = String.Empty;
            try
            {
                tmp = ((m_combo_item)comboBox.SelectedItem).combo_code.ToString();
            }
            catch
            {
                tmp = "NONE";
            }
            PCPUB.m_fill_combo(lst_vendor, tmp);
        }

        private void sc_main_list_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }

    }

}